package com.dzirtbry.MedicineAnalizer.Types;

import com.dzirtbry.MedicineAnalizer.Analizer;

public class MedicineTransactionList extends AbstractSaveableList<MedicineTransaction>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1371084249733963771L;
	
	private String fileName = ""; 
	
	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public Object getCell (int x, int y) {
		switch (y) {
		case 0: return this.get(x).getId();
		case 1: return this.get(x).getName();
		case 2: return this.get(x).getPrice();
		case 3: return this.get(x).getTransactionAmount();
		}
		return null;
	}
	
	public String getSummary(Medicine med) {
		Character abc = Analizer.ABC(med, this);
		Character xyz = Analizer.XYZ(med, this);
		String amountString = "";
		// TODO: Convert to ID selection
		
		for (MedicineTransaction medTransaction: this) {
			if (medTransaction.getMedicine().equals(med)) {
				amountString = String.valueOf(medTransaction.getTransactionAmount());
				break;
			}
		}
		
		return amountString + ", " + abc + ", " + xyz; 
	}

}
